﻿namespace MicroCloud.Entity.SqlServer
{
    /// <summary>
    /// SqlServer实体框架核心模块(SqlServerEntityFrameworkCore)
    /// </summary>
    [Description("SqlServer实体框架核心模块(SqlServerEFCore)")]
    public class SqlServerEntityFrameworkCorePack : EntityFrameworkCorePackBase
    {
        #region "属性"
        #region "获取 模块级别"
        /// <summary>
        /// 获取 模块级别
        /// </summary>
        public override PackLevel Level => PackLevel.Framework;
        #endregion
        #region "获取 模块启动顺序编号"
        /// <summary>
        /// 获取 模块启动顺序编号，模块启动的顺序先按级别启动，级别内部再按此顺序启动
        /// </summary>
        public override int OrderNo => 1;
        #endregion
        #region "获取 数据库类型"
        /// <summary>
        /// 获取 数据库类型
        /// </summary>
        protected override DatabaseType DatabaseType => DatabaseType.SqlServer;
        #endregion

        #endregion

        #region "方法"
        #region "将模块服务添加到依赖注入服务容器中"
        /// <summary>
        /// 将模块服务添加到依赖注入服务容器中
        /// </summary>
        /// <param name="services">依赖注入服务容器</param>
        /// <returns></returns>
        public override IServiceCollection AddServices(IServiceCollection services)
        {
            services = base.AddServices(services);

            services.AddSingleton<IEntityBatchConfiguration, BatchEntityConfiguration>();

            services.AddSingleton<ISequentialGuidGenerator, SqlServerSequentialGuidGenerator>();
            services.AddScoped(typeof(ISqlExecutor<,>), typeof(SqlServerDapperSqlExecutor<,>));
            services.AddSingleton<IDbContextOptionsBuilderDriveHandler, SqlServerDbContextOptionsBuilderDriveHandler>();

            return services;
        }
        #endregion

        #endregion

    }

}
